const chalk = require('chalk');
const inquirer = require('inquirer');
const fileOp = require('../lib/file.js');
// 当前目录
const dirPath = `${process.cwd()}/src/`;
module.exports = (program) => {
    program
        .command('pxToRem')
        .alias('px')
        .description('将 px 转换为 rem')
        .action(option => {
            const promps = [];
            console.log(chalk.red('\n单位转换开始\n'));
            promps.push({
                type: 'list',
                name: 'convert',
                message: '请选择转换方式',
                choices: [{
                    name: '单个文件转换',
                    value: 'single',
                },
                {
                    name: '多个文件转换',
                    value: 'more',
                },
                {
                    name: '全部文件转换',
                    value: 'all',
                },
                ],
            });
            inquirer.prompt(promps).then(function (answers) {
                if (answers.convert === 'single') {
                    console.log(chalk.red('执行单个css,less,scss文件转换，需要输入文件名称'));
                    fileOp.getSingleCss(dirPath);
                    return;
                }
                if (answers.convert === 'more') {
                    console.log(chalk.red('执行选择的css,less,scss文件转换，请选择要转换的文件名称'));
                    fileOp.getMoreCss(dirPath);
                    return;
                }
                if (answers.convert === 'all') {
                    console.log(chalk.red('全部css,less,scss文件转换ing...'));
                    fileOp.getAllCss(dirPath)
                    return;
                }
            })
        })
}
